package com.cloudwise.monitoring_system.controller.clickhouseController;

import com.cloudwise.monitoring_system.entity.MonitorValue;
import com.cloudwise.monitoring_system.service.clickhouseService.CkMonitorValueService;
import com.cloudwise.monitoring_system.util.Result;
import com.cloudwise.monitoring_system.util.ReturnStatus;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author Reisen
 * @description: clickhouse 监控项controller层
 * @date 2021/6/2 14:04
 */
@Controller
@RequestMapping("ckMonitor")
@ApiOperation("clickhouse监控项数据控制器")
public class CkMonitorValueController {
    @Resource
    private CkMonitorValueService ckMonitorValueService;

    /**
     * clickhouse 查询所有
     * @param monitorValue
     * @return
     */
    @ResponseBody
    @GetMapping("ckQueryAll")
    @ApiOperation("查询所有监控项数据")
    public Result query(@ApiParam("监控项数据")MonitorValue monitorValue){
        return new Result(ReturnStatus.SUCCESS.getCode(),
                ReturnStatus.SUCCESS.getMessage(), 0,
                this.ckMonitorValueService.ckQueryAll(monitorValue));

    }

    /**
     * 新增一条监控项数据
     * @param monitorValue
     * @return
     */
    @ResponseBody
    @PostMapping("ckInsert")
    @ApiOperation("新增一条监控项数据")
    public Result insert(@ApiParam("监控项数据")MonitorValue monitorValue){
        return new Result(ReturnStatus.SUCCESS.getCode(),
                ReturnStatus.SUCCESS.getMessage(),
                0,this.ckMonitorValueService.insert(monitorValue));
    }
}
